Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ref: fix typing of jira_server.integration #86388

Merged
merged 2 commits into from
Mar 6, 2025

Conversation

asottile-sentry
Copy link
Member

No description provided.

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Mar 5, 2025
Copy link

codecov bot commented Mar 5, 2025

Codecov Report

Attention: Patch coverage is 89.00000% with 11 lines in your changes missing coverage. Please review.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/sentry/integrations/jira_server/integration.py 83.33% 10 Missing ⚠️
src/sentry/integrations/base.py 88.88% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #86388      +/-   ##
==========================================
- Coverage   87.85%   87.84%   -0.01%     
==========================================
  Files        9736     9736              
  Lines      552361   552354       -7     
  Branches    21539    21539              
==========================================
- Hits       485258   485217      -41     
- Misses      66717    66751      +34     
  Partials      386      386              

Comment on lines -359 to +370
self._org_integration: RpcOrganizationIntegration | None

@property
def org_integration(self) -> RpcOrganizationIntegration | None:
@cached_property
def org_integration(self) -> RpcOrganizationIntegration:
from sentry.integrations.services.integration import integration_service

if not hasattr(self, "_org_integration"):
self._org_integration = integration_service.get_organization_integration(
integration_id=self.model.id,
organization_id=self.organization_id,
)
return self._org_integration

@org_integration.setter
def org_integration(self, org_integration: RpcOrganizationIntegration) -> None:
self._org_integration = org_integration
integration = integration_service.get_organization_integration(
integration_id=self.model.id,
organization_id=self.organization_id,
)
if integration is None:
raise NotFound("missing org_integration")
return integration
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the "big" change in this changeset that I'm not certain about -- it makes it so that we can't construct an integration with a missing OrganizationIntegration

I'm not certain that this is correct -- but it seems most of the integrations do not handle the case where this is missing and as far as I can understand it doesn't really make sense to have an integration not associated with an organization -- will need the domain owners to confirm this idea though

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I brought this up with my team to double check, and we think this is a fair assumption to make. Most of our integrations operate with the assumption that we have an org integration already, so it should be fine to handle the potentially few cases that don't explicitly with a try/catch.

@asottile-sentry asottile-sentry marked this pull request as ready for review March 5, 2025 16:37
@asottile-sentry asottile-sentry requested review from a team as code owners March 5, 2025 16:37
@asottile-sentry asottile-sentry requested review from a team March 5, 2025 16:37
Copy link
Member

@GabeVillalobos GabeVillalobos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good, thank you!

Comment on lines +550 to +554
integration_service.update_integration(
integration_id=self.model.id,
name=self.model.name,
metadata=self.model.metadata,
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this change made to address the case where model is an RpcIntegration?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep -- it would otherwise crash with AttributeError: save

Comment on lines -359 to +370
self._org_integration: RpcOrganizationIntegration | None

@property
def org_integration(self) -> RpcOrganizationIntegration | None:
@cached_property
def org_integration(self) -> RpcOrganizationIntegration:
from sentry.integrations.services.integration import integration_service

if not hasattr(self, "_org_integration"):
self._org_integration = integration_service.get_organization_integration(
integration_id=self.model.id,
organization_id=self.organization_id,
)
return self._org_integration

@org_integration.setter
def org_integration(self, org_integration: RpcOrganizationIntegration) -> None:
self._org_integration = org_integration
integration = integration_service.get_organization_integration(
integration_id=self.model.id,
organization_id=self.organization_id,
)
if integration is None:
raise NotFound("missing org_integration")
return integration
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I brought this up with my team to double check, and we think this is a fair assumption to make. Most of our integrations operate with the assumption that we have an org integration already, so it should be fine to handle the potentially few cases that don't explicitly with a try/catch.

@asottile-sentry asottile-sentry merged commit e857218 into master Mar 6, 2025
49 checks passed
@asottile-sentry asottile-sentry deleted the asottile-typing-jira-server-integration branch March 6, 2025 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scope: Backend Automatically applied to PRs that change backend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants